package com.example.safeassistan.train.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.safeassistan.R;
import com.example.safeassistan.train.model.DownLoad;
import com.example.safeassistan.train.util.MaterialUtil;

import java.util.List;


public class DownLoadAdapter extends BaseQuickAdapter<DownLoad.DataBean, BaseViewHolder> {

    public DownLoadAdapter(List<DownLoad.DataBean> data) {

        super(R.layout.item_download_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DownLoad.DataBean item) {

        ImageView ivFileType=helper.getView(R.id.ivFileType);
        if(!item.isVisible()){
            helper.getView(R.id.ivSelect).setVisibility(View.GONE);
        }else {
            helper.getView(R.id.ivSelect).setVisibility(View.VISIBLE);
        }

        switch (item.getFileType()){
            case "doc":
            case "docx":
                ivFileType.setImageResource(R.mipmap.iocn_word);
                break;
            case "ppt":
                ivFileType.setImageResource(R.mipmap.icon_ppt);
                break;

            case "pdf":
                ivFileType.setImageResource(R.mipmap.icon_pdf);
                break;
            case "xlsl":
                ivFileType.setImageResource(R.mipmap.icon_excel);
                break;
        }

        ImageView ivSelect = helper.getView(R.id.ivSelect);
        MaterialUtil.checkItem(item.isSelect(), ivSelect);
        helper.addOnClickListener(R.id.ivSelect);

        helper.setText(R.id.tvName,item.getTitle());

    }
}
